using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace YT.Controls
{
    public partial class ButtonEx : System.Windows.Forms.Button     
    {
        public enum ImageStype
        {
            DownArrow,
            UpArrow,
            LeftArrow,
            RightArrow,
            SearchByKey,
            DownDownArrow,
            UpUpArrow,
            LeftLeftArrow,
            RightRightArrow,
            OpenWindow
        }

        public enum ImageSize
        {
            Genteral,
            Smaller
        }

        private ImageStype m_buttonImage = ImageStype.DownArrow;
        private ImageSize m_ImageSize=ImageSize.Genteral ;
        public ButtonEx()
        {
            InitializeComponent();
            this.ImageList=this.iglButtoneX;
            this.ImageIndex = 0;
            //this.DragOver += new DragEventHandler(button_DragOver);
            //this.DragLeave += new EventHandler(button_DragLeave);    

        }
        private void button_DragLeave(object sender, EventArgs e)
        {
            this.Invalidate(); 
        }
        private void button_DragOver(object sender, DragEventArgs e)
        {
            this.Invalidate(); 
        }
        //protected override void OnPaintBackground(PaintEventArgs e)
        //{
        //    //base.OnPaintBackground(e);
        //    Graphics g = e.Graphics;
        //    Pen p = new Pen(Color.SteelBlue, 1);
        //    g.DrawRectangle(p, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
             
        //}

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            if (this.FlatAppearance.BorderSize > 0 && (this.FlatStyle == FlatStyle.Popup || this.FlatStyle == FlatStyle.Flat))
            {
                Graphics g = e.Graphics;
                //Brush b = new SolidBrush(this.BackColor);
                //g.FillRectangle(b, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
    
                Pen p = new Pen(Color.SteelBlue, 1);
                g.DrawRectangle(p, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
              //  g.DrawImage(this.Image, (this.Width - this.Image.Width) / 2, (this.Height - this.Image.Height) / 2);  
               // this.Invalidate(ClientRectangle );
               // e.Graphics.Flush();
              //  
              //  base.OnPaintBackground(e);
                //  base.Refresh(); 

    //            g.FillRectangle(new LinearGradientBrush(ClientRectangle,
    //BackColor1, BackColor2, 90, false), ClientRectangle);
    //            g.DrawString(Text, Font, new SolidBrush(ForeColor),
    //                ClientRectangle, _txtFormat);



            }

        }

        public ImageStype ButtonImage
        {
            get
            {
                return m_buttonImage;
            }
            set
            {
                m_buttonImage = value;
                switch (m_buttonImage)
                {
                    case ImageStype.DownArrow:
                        this.ImageIndex = 0;
                        break;

                    case ImageStype.UpArrow :
                        this.ImageIndex = 1;
                        break;

                    case ImageStype.LeftArrow :
                        this.ImageIndex = 2;
                        break;

                    case ImageStype.RightArrow :
                        this.ImageIndex = 3;
                        break;

                    case ImageStype.SearchByKey :
                        this.ImageIndex = 4;
                        break;

                    case ImageStype.DownDownArrow :
                        this.ImageIndex = 5;
                        break;

                    case ImageStype.UpUpArrow :
                        this.ImageIndex = 6;
                        break;

                    case ImageStype.LeftLeftArrow :
                        this.ImageIndex = 7;
                        break;

                    case ImageStype.RightRightArrow :
                        this.ImageIndex = 8;
                        break;

                    case ImageStype.OpenWindow:
                        this.ImageIndex = 9;
                        break;
                }
                
            }
        }

        public ImageSize ButtonImageSize
        {
            get
            {
                return m_ImageSize; 
            }
            set
            {
                m_ImageSize = value;
                this.ImageList = (m_ImageSize == ImageSize.Genteral ? this.iglButtoneX : this.iglButtonExSmaller);    

            }
        }

        

    }
}
